import AccessEnum from "@/access/accessEnum";
// import { builtinRules } from "eslint/use-at-your-own-risk";

const checkAccess = (loginUser, needAccess = AccessEnum.NOT_LOGIN) => {
  const loginUserAccess = loginUser?.userRole ?? AccessEnum.NOT_LOGIN;
  if (needAccess === AccessEnum.NOT_LOGIN) {
    return true;
  }
  if (needAccess === AccessEnum.USER) {
    if (loginUserAccess !== AccessEnum.USER) {
      return false;
    }
  }
  if (needAccess === AccessEnum.WORKER) {
    if (loginUserAccess !== AccessEnum.WORKER) {
      return false;
    }
  }
  if (needAccess === AccessEnum.ADMIN) {
    if (loginUserAccess !== AccessEnum.ADMIN) {
      return false;
    }
  }
  return true;
};
export default checkAccess;
